package com.yanqu.road.server.cmd.union.cross;

import com.yanqu.road.entity.enums.eUnionPosition;
import com.yanqu.road.entity.union.UnionMember;
import com.yanqu.road.pb.union.UnionProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_UNION_SET_FLAG_REAd,desc = "读会旗")
public class ReadUnionFlagCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        //String unionUid = player.getUserInfo().getUnionUid();
        UnionProto.ReadUnionFalgReq flagReq = UnionProto.ReadUnionFalgReq.parseFrom(packet.getBytes());
        UnionMember unionMember = CrossUnionMgr.getUnionMember(player.getUserId());
        if (unionMember == null) {
            return;
        }
        if (unionMember.getPosition() == eUnionPosition.Master.getValue()) {
            //只有会长才可以
            //UnionMgr.readUnionFlag(unionMember.getUnionUid());
            player.sendPacket(Protocol.C_UNION_SET_FLAG_READ, flagReq.toBuilder());
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
